function xhr(options) {
  let url = options.url,
    method = options.method || "post",
    type = options.type || "x-www-form-urlencoded",
    data = options.data,
    fnSucc = options.onSuccess,
    fnFaild = options.onFaild;
  var xhr;
  if (window.XMLHttpRequest) {
    xhr = new XMLHttpRequest();
  } else {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xhr.open(`${method}`, `${url}`, true);
  if (method.toLowerCase() == "post") {
    xhr.setRequestHeader("content-type", `application/${type}`);
    xhr.send(JSON.stringify(data));
  } else {
    xhr.send();
  }
  xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
      fnSucc(xhr.responseText);
    } else {
      fnFaild(xhr.status);
    }
  };
}
